package com.loanafter.fox.monitor.logback.event;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @author jasonli@kuainiugroup.com
 * @date 2020/7/30 下午5:43
 */
public class Event {

    private final UUID id;
    private String message;
    private String messagePrefix;
    /**
     * The record severity.
     */
    private Level level;
    /**
     * The name of the logger which created the record.
     */
    private String logger;
    /**
     * Exact time when the logging occurred.
     */
    private Date timestamp;
    /**
     * A map or list of tags for this event.
     * <p>
     * Automatically created with a Map that is made unmodifiable by the {@link EventBuilder}.
     */
    private Map<String, String> tags = new HashMap<>();

    Event(UUID id) {
        if (id == null) {
            throw new IllegalArgumentException("The id can't be null");
        }
        this.id = id;
    }

    public UUID getId() {
        return id;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

    public String getLogger() {
        return logger;
    }

    public void setLogger(String logger) {
        this.logger = logger;
    }

    public Map<String, String> getTags() {
        return tags;
    }

    public void setTags(Map<String, String> tags) {
        this.tags = tags;
    }

    public String getMessagePrefix() {
        return messagePrefix;
    }

    public void setMessagePrefix(String messagePrefix) {
        this.messagePrefix = messagePrefix;
    }

    /**
     * Levels of log available in Sentry.
     */
    public enum Level {
        /**
         * Fatal is the highest form of log available, use it for unrecoverable issues.
         */
        FATAL,
        /**
         * Error denotes an unexpected behaviour that prevented the code to work properly.
         */
        ERROR,
        /**
         * Warning should be used to define logs generated by expected and handled bad behaviour.
         */
        WARNING,
        /**
         * Info is used to give general details on the running application, usually only messages.
         */
        INFO,
        /**
         * Debug information to track every detail of the application execution process.
         */
        DEBUG
    }
}
